<template>
    <div class="personalized-recommended">
        <div class="w-full">
            <recommended-top-bar top-bar-name="个性化推荐">
            </recommended-top-bar>
            <div>
                <div class="personalized-recommended-cart-item">
                    <div
                        v-for="(item, index) in result.slice(1, 6)"
                        :key="index">
                        <song-shot-information-cart img-size="150" :detail="item" @click="getListDetail(item.id)"></song-shot-information-cart>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import RecommendedTopBar from "@/views/recommend/RecommendedTopBar";
import SongShotInformationCart from "@/components/song/SongShotInformationCart";
import {onMounted, ref} from "vue";
import {getPersonalized} from "@/network/song/song-list";
import {useRouter} from "vue-router";

export default {
    name: "PersonalizedRecommendation",
    components: {
        RecommendedTopBar,
        SongShotInformationCart
    },
    setup() {
        const result = ref([]);
        const router = useRouter();
        onMounted(() => {
            getPersonalized().then(res => {
                result.value = res.data.result;
            })
        })
        // 根据ＩＤ获取歌单详情
        const getListDetail = (id) => {
            router.push({path: '/playlist', query: {id}});
        }
        return {
            result,
            getListDetail
        }
    }
}
</script>

<style lang="scss" scoped>
.personalized-recommended {
    @apply flex;
    .personalized-recommended-cart-item {
        @apply m-4 grid grid-cols-5 gap-12;
    }
}
</style>